﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Speech.Synthesis;
using System.Text;
using System.Threading.Tasks;

namespace DigiMate
{
	public class Speaker
	{

		private static SpeechSynthesizer synth = new SpeechSynthesizer(); 

		static Speaker()
		{
			Console.WriteLine("Installed voices:");
			foreach (var v in synth.GetInstalledVoices().Select(v => v.VoiceInfo))
			{
				Console.WriteLine("Name:{0}, Gender:{1}, Age:{2}",
				  v.Description, v.Gender, v.Age);
			}

			// select male senior (if it exists)
			synth.SelectVoiceByHints(VoiceGender.Female, VoiceAge.Adult);
			synth.Rate = 2;
		}

		public static void Speak(string text, string suffix)
		{
			PromptBuilder song = new PromptBuilder();
			song.AppendText(text + ". " + suffix);

			synth.Speak(song);
		}

		public static void Speak(string text)
		{
			Speak(text, "");
		}

		public static void SpeakOk(string text)
		{
			Speak(text, "Ok");
		}
	}
}
